(function (global) {
    //自定义
    var LiteGraph = global.LiteGraph;

    // 创建自定义HTTP请求节点类
    function CustomHttpRequestNode() {
        this.addInput("地址", "string");
        this.addInput("请求方法", "string");
        this.addOutput("Response", "object");
    }

    CustomHttpRequestNode.title = "http请求";

    // 执行节点操作
    CustomHttpRequestNode.prototype.onExecute = function () {
        // 从输入端获取URL和HTTP方法
        var url = this.getInputData(0);
        var method = this.getInputData(1);

        // 执行HTTP请求，这里使用了简化示例，你可以根据需要使用更复杂的HTTP请求库
        if (url && method) {
            fetch(url, { method: method })
                .then(function (response) {
                    return response.text();
                })
                .then(function (data) {
                    // 将响应数据输出到节点的输出端
                    this.setOutputData(0, data.substring(0, 100));
                }.bind(this))
                .catch(function (error) {
                    console.error("Error in HTTP request:", error);
                });
        }
    };

    // 注册自定义节点类
    LiteGraph.registerNodeType("自定义/http_request", CustomHttpRequestNode);
    //#endregion


    //1
    var title = "变量递增"
    CustomAdd.title = title;
    function CustomAdd() {
        this.addInput("输入数字", "number");
        this.addOutput("输出数字", "number");
    }
    //2
    CustomAdd.prototype.onExecute = function () {
        var num = this.getInputData(0);
        num++;
        this.setOutputData(0, num);
    }
    //3
    LiteGraph.registerNodeType("自定义/" + title, CustomAdd);

    //1
    var title = "图片显示"
    CustomAdd.title = title;
    function CustomAdd() {
        this.addInput("图片地址", "string");
        this.addOutput("输出数字", "number");
    }
    //2
    CustomAdd.prototype.onExecute = function () {
        var num = this.getInputData(0);
        num++;
        this.setOutputData(0, num);
    }
    //3
    LiteGraph.registerNodeType("自定义/" + title, CustomAdd);

})(this);
